﻿using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataSet1TableAdapters;

public partial class nedelu_bildes : System.Web.UI.Page
{
    int PageElementNumber = 10;
    PagedDataSource objPds = new PagedDataSource();
    nedBildeTableAdapter nedBildeTa = new nedBildeTableAdapter();
    DataSet1.nedBildeDataTable nedBildeDa = new DataSet1.nedBildeDataTable();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        ItemsGet();
    }

    private void ItemsGet()
    {
        //if (Page.IsPostBack == false)
        //{
        nedBildeDa = nedBildeTa.GetnedBilde();

        //  PagedDataSource objPds = new PagedDataSource();
        objPds.DataSource = nedBildeDa.DefaultView;// Tables[0].DefaultView;

        // Indicate that the data should be paged
        objPds.AllowPaging = true;

        // Set the number of items you wish to display per page
        objPds.PageSize = PageElementNumber;

        // Set the PagedDataSource's current page
        objPds.CurrentPageIndex = CurrentPage;// -1;

        lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
        + objPds.PageCount.ToString();

        // Disable Prev or Next buttons if necessary
        cmdPrev.Enabled = !objPds.IsFirstPage;
        cmdNext.Enabled = !objPds.IsLastPage;

        Repeater1.DataSource = objPds;
        Repeater1.DataBind();
        //}
    }

    public int CurrentPage
    {
        get
        { // look for current page in ViewState
            object o = this.ViewState["_CurrentPage"];
            if (o == null)
                return 0; // default page index of 0
            else
                return (int)o;
        }
        set
        {
            this.ViewState["_CurrentPage"] = value;
        }
    }


    protected void cmdNext_Click1(object sender, EventArgs e)
    {// Set viewstate variable to the next page
        CurrentPage += 1;

        // Reload control
        ItemsGet();
    }
    protected void cmdPrev_Click(object sender, EventArgs e)
    {  // Set viewstate variable to the previous page
        CurrentPage -= 1;

        // Reload control
        ItemsGet();
    }
}
